<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/sunzbase.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="resources/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<z:resource items="easyui"></z:resource>
<title>Insert title here</title>
<link rel="stylesheet" href="resources/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
</head>
<body>
<div class="page-container">
	<form action="" method="post" class="form form-horizontal" id="form-category-add">
		<div id="tab-category" class="HuiTab">
			<div class="tabCon" style="display:block;">
				<div class="row cl">
					
					<div class="formControls col-sm-9" style="padding-left:40px;"><i class="Hui-iconfont">&#xe63e;</i>&nbsp;&nbsp;${acc.accName}</div>
					<input type="hidden" id="fileId" name="fileId" value="${acc.id}"/>					
				</div>
				<div class="row cl">
					<div style="padding-left:40px;" class="form-label col-sm-4">
						<span class="c-red">*</span>
						移动到：</div>
					<div class="formControls col-sm-8">
						<ul id="folderZtree" class="ztree" style="border-style: solid; border-width: 1px;width:80%;border-color:#e0e1e5; margin: 0 auto;height:200px;overflow-y: auto;  
            overflow-x: hidden;"></ul>
						<input id="newFolderId" name="newFolderId" type="hidden" />
						<!-- <input id="newFolderName" name="newFolderName" /> -->
					</div>
				</div>
			</div>			
		</div>
		<div class="row cl">
			<div class="col-9 col-offset-3">
				<input id="moveSubmit" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</div>
</body>
<script type="text/javascript" src="resources/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript">
 	var zTreeObj,
	setting = {
		view: {
			selectedMulti: false
		},
		data: {
			simpleData: {
				enable: true,
				idKey: "id",
				pIdKey: "pId",
				rootPId: 0
			},			
		},
	callback: {  
        onClick: function(treeId, treeNode) {  
            var treeObj = $.fn.zTree.getZTreeObj(treeNode);  
            var selectedNode = treeObj.getSelectedNodes()[0];  
            $("#newFolderId").val(selectedNode.id);  
            $("#newFolderName").val(selectedNode.name);  
       		}  
		}
	 }
	var treeNodes=[];
	$(function(){  
	    $.ajax({  
	        async : false,  
	        cache:false,  
	        type: 'POST',  
	        dataType : "json",  
	        url: "note/getFolders",//请求的action路径  
	        error: function () {//请求失败处理函数  
	            alert('请求失败');  
	        },  
	        success:function(result){ //请求成功后处理函数。    	        	
	           // alert(result.data); 
	       		 var data=result.data;
	       		 for(var i=0;i<data.length;i++){
	       			 if(data[i].folderDefaut==0){
	       				var node= {"id":data[i].id, "pId":data[i].folderParentId, "name":data[i].folderName};
		       			treeNodes.push(node); 
	       			 }	       				       			 
	       		 }  
	        }  
	    });  	  
	 //   zTree = $("#folderZtree").zTree(setting, treeNodes);  
	}); 
	$(document).ready(function(){
		zTreeObj = $.fn.zTree.init($("#folderZtree"), setting, treeNodes);	
	}); 
	$("#moveSubmit").click(function(){		
		if($("#newFolderId").val()==""){
			alert("请先选择移动位置！");
			return false;
		}
		var fileId=$("#fileId").val();		
		var newFolder=$("#newFolderId").val();
		$.ajax({
			url:"note/fileMoveSubmit",
			type:"POST",
			data:{fileId:fileId,newFolderId:newFolder},
			success:function(result){
				if(result.success){
					layer.msg("移动文件成功！",{icon:6});				
				}else{
					layer.msg(result.msg);
				}
				setTimeout(function(){
					var index = parent.layer.getFrameIndex(window.name);
					parent.$('#fileSearch').click();
					parent.layer.close(index);
				}, 2000);
			}
		});
	})
</script>
</html>